package com.example.adminbackend.client;

import com.example.adminbackend.entity.Ad;
import com.example.adminbackend.entity.AdCategory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@FeignClient(name = "ad-service")
public interface AdServiceClient {

    @GetMapping("/api/ads")
    List<Ad> findAll();

    @GetMapping("/api/ads/{id}")
    Ad findById(@PathVariable("id") Integer id);

    @PostMapping("/api/ads")
    String save(@RequestBody Ad ad);

    @PutMapping("/api/ads/{id}")
    String update(@PathVariable("id") Integer id, @RequestBody Ad ad);

    @DeleteMapping("/api/ads/{id}")
    String delete(@PathVariable("id") Integer id);

    @GetMapping("/api/ads/categories")
    List<AdCategory> findAllCategories();

    @GetMapping("/api/ads/categories/{id}")
    AdCategory findCategoryById(@PathVariable("id") Integer id);

    @PostMapping("/api/ads/categories")
    String saveCategory(@RequestBody AdCategory category);

    @PutMapping("/api/ads/categories/{id}")
    String updateCategory(@PathVariable("id") Integer id, @RequestBody AdCategory category);

    @DeleteMapping("/api/ads/categories/{id}")
    String deleteCategory(@PathVariable("id") Integer id);

    @PostMapping(value = "/api/ads/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String uploadImage(@RequestPart("file") MultipartFile file);
}